#ifndef __SHADER_HPP__
#define __SHADER_HPP__

#include <string>
#include <unordered_map>

#include "glm.hpp"

struct ShaderSource {
    std::string vs;
    std::string fs;
};

class Shader {
    std::unordered_map<std::string, int > _uniformLocationCache;
    unsigned int _rendererID;
    unsigned int compile( unsigned int type, std::string const& source );
    ShaderSource parse( std::string const& filePath );

    int _getUniformLocation( const std::string& name );
public:
    Shader( std::string const& filePath );
    ~Shader();

    void bind() const;
    void unbind() const;
    
    void uniformMat3f( const std::string& name, glm::mat3 const& m );
    void uniformMat4f( const std::string& name, glm::mat4 const& m );

    void uniform1i( const std::string& name, int i0 );
    void uniform1iv( const std::string& name, unsigned int count, int * iv );
    void uniform2i( const std::string& name, int i0, int i1);
    void uniform3i( const std::string& name, int i0, int i1, int i2 );
    void uniform4i( const std::string& name, int i0, int i1, int i2, int i3 );

    void uniform1f( const std::string& name, float v0 );
    void uniform2f( const std::string& name, float v0, float v1 );
    void uniform3f( const std::string& name, float v0, float v1, float v2 );
    void uniform4f( const std::string& name, float v0, float v1, float v2, float v3 );
};


#endif // !__SHADER_HPP__
